function delmyFn(id){
	ZeaiM.confirmUp({title:'真的要删除么？',cancel:'取消',ok:'确定',okfn:function(){
		zeai.ajax(MHOST+'/qun_trend'+zeai.ajxext+'submitok=delmy&id='+id+'&qid='+qid+'&t='+t,function(e){var rs=zeai.jsoneval(e);
			if (rs.flag == 1){
				o('dl'+id).remove();
			}else{zeai.msg(rs.msg);}
		});
	}});
}

function contentFn(){
	var ic = this.value.length;
	if (ic>500){
		this.value = this.value.substring(0,500);
		zeai.msg(0);zeai.msg('最多500字');
		ic = 500;
		return false;
	}
	inpttext.html(ic);
}
//up
function addli(url){
	var li = document.createElement('li');
	var img = document.createElement('img');
	var b = document.createElement('b');
	li.appendChild(img);li.appendChild(b);ul.appendChild(li);
	if(browser=='wx'){
		var local=url[0],url=url[1];
		localIds.push(local);
		img.src = local;
	}else{
		img.src = url;
	}
	trend_pic_Slist.push(url);
	morelist.value = arrReset(trend_pic_Slist).join(",");
	b.onclick = function (){
		li.parentNode.removeChild(li);
		trend_pic_Slist = trend_pic_Slist.remove(url);
		morelist.value  = arrReset(trend_pic_Slist).join(",");
		if(browser=='wx'){
			localIds = localIds.remove(url);
			localIds = arrReset(localIds);
		}
	}
	img.onclick = function (){
		if(browser=='wx'){
			ZeaiM.piczoom({browser:browser,b:local,list:localIds});
		}else{
			ZeaiM.piczoom({browser:browser,b:url.replace('_s.','_b.')});
		}
	}
}
function arrLength(ARR){
	var l=0;
	for(var k=0;k<ARR.length;k++) {
		if(typeof(ARR[k]) == "string")l++;
	}
	return l;
}
function arrReset(ARR){
	var l=[];
	for(var k=0;k<ARR.length;k++) {
		if(typeof(ARR[k]) == "string")l.push(ARR[k]);
	}
	return l;
}
function trend_btn_saveFn(){
	var Lth=arrLength(trend_pic_Slist);
	if(Lth>6){zeai.msg('最多只能传6张照片，请删减');return false;}
	var C=zeai.clearhtml(content.value);
	if (zeai.empty(C) || C.length > 140){zeai.msg('亲，该说点什么吧～',content);return false;}
	zeai.confirm('确定提交么？<br>以下情形话题将被删除或封号：<br>1．请勿在内容里留下任何形式的联系方法<br>2．请勿发表涉黄涉政言论<br>3．请勿发表不文明或辱骂攻击他人言论',function(){
		zeai.msg("请稍后，正在保存");
		content.value = C.substring(0,140);
		zeai.ajax({url:MHOST+'/qun_trend.php?submitok=addupdate&qid='+qid+'&t='+t,form:trendbox},function(e){var rs=zeai.jsoneval(e);
			zeai.msg(0);zeai.msg(rs.msg);
			if(rs.flag==1){
				setTimeout(function(){zeai.openurl(MHOST+'/qun_trend.php?qid='+qid+'&t='+t);},1000);
			}
		});
	});
}
function btnpicFn(){
	var Lth=arrLength(trend_pic_Slist);
	if(Lth>=6){zeai.msg('最多只能传6张哦');return;}
	if(is_h5app()){
		app_uploads({url:MHOST+'/qun_trend.php?submitok=ajax_photo_up_app&qid='+qid+'&t='+t,num:1},function(e){
			var rs=zeai.jsoneval(e);
			addli(up2+rs._s);
		});
	}else{
		photoUp({
			onclick:false,
			btnadd:ul,
			url:MHOST+'/qun_trend.php?qid='+qid+'&t='+t,
			submitokBef:"ajax_photo_",
			multiple:6,
			wxtmp:true,
			li:function(e){
				if(browser=='wx'){
					addli(e);
				}else{
					addli(up2+e._s);
				}
			},
			end:function(e){
				zeai.msg(0);
				//if(browser=='wx'){
					//qun_trend_pic_Slist = e;
					//morelist.value = e.join(",");
				//}
			}
		});
	}
}
//piclist
function pFn(b,list){
	list = list.split(',');
	var plist = [];
	for(var k=0;k<list.length;k++) {
		plist.push(list[k]);
	}
	ZeaiM.piczoom({browser:browser,b:b,list:list});
}

function agreeFn(that,id){
	var dl=o('dl'+id);
	var agreeDIV = dl.getElementsByTagName("div")[0].children;
	var agree = agreeDIV[1],agreehtml = agree.getElementsByTagName("span")[0];
	if (agree.className != 'ed'){

			var tid = id;
			zeai.ajax({url:MHOST+'/qun_trend'+zeai.extname,data:{submitok:'ajax_agree',tid:tid,qid:qid,t:t}},function(e){rs=zeai.jsoneval(e);
				if(rs.flag==1){
					agree.className = 'ed';
					agree.onclick   = function (){}
					agreehtml.html(parseInt(agreehtml.innerHTML)+1);
					var b=agreehtml.parentNode.getElementsByTagName("b")[0];b.show();
					var img = document.createElement('img');img.src = rs.imgurl;if (!zeai.empty(img.classname))img.className = rs.classname;//img.setAttribute('uid',rs.uid);
					img.onclick=function(){zeai.openurl(MHOST+'/u.php?uid='+rs.uid);}
					var ul=dl.getElementsByTagName("ul")[0];
					if (rs.num == 1){
						var em = document.createElement('em');
						if(zeai.empty(ul)){
							var j  = document.createElement('div');j.className = 'j';dl.appendChild(j);
							dl.appendChild(em);
						}else{
							ul.parentNode.insertBefore(em,ul);
						}
					}else{
						var em  = dl.getElementsByTagName("em")[0];
					}
					em.insertBefore(img,em.firstChild);
				}else{zeai.msg(rs.msg);}
			});

	}

	
}
function bbsFn(that,id){
	if(!zeai.empty(o('trendbbs'))){o('trendbbs').parentNode.remove();return false;}
	if(!zeai.empty(o('trendbbs'))){o('trendbbs').parentNode.remove();}
	var bbs=zeai.addtag('div');bbs.class('trend_bbsadd');
	var textarea=zeai.addtag('textarea');textarea.class('textarea small_big');textarea.id='trendbbs';textarea.setAttribute("placeholder","请文明发言");
	var btn=zeai.addtag('button');btn.class('btn size2 HONG small_big');btn.type='button';btn.html('提交评论');
	bbs.append(textarea);bbs.append(btn);
	var dl=o('dl'+id);
	dl.insertBefore(bbs,that.parentNode.nextSibling);
	textarea.onblur=function(){setTimeout(function(){window.scrollTo(0,0)},200);}
	btn.onclick =function (){
		textarea.value = zeai.clearhtml(textarea.value);
		if(zeai.empty(textarea.value)){zeai.msg('请输入内容(200字以内)');return false;}
		var fid=id;
		zeai.confirm('<center class="S18 B">温馨提醒</center><br>确定提交么？<br>以下情形话题将被删除或封号：<br>1．请勿在内容留下任何形式联系方法<br>2．请勿发表涉黄涉政言论<br>3．请勿发表不文明或辱骂攻击他人言论<br><br>',function(){
			zeai.ajax({url:MHOST+'/qun_trend'+zeai.ajxext+'submitok=trend_bbs_add',data:{fid:fid,content:textarea.value,qid:qid,t:t}},function(e){var rs=zeai.jsoneval(e);
				zeai.msg(0);zeai.msg(rs.msg);
				if(rs.flag==1){
					var agreeDIV = dl.getElementsByTagName("div")[0].children;
					var agree = agreeDIV[1],agreehtml = agree.getElementsByTagName("span")[0],bbshtml = that.getElementsByTagName("span")[0];
					bbshtml.html(parseInt(bbshtml.innerHTML)+1);
					var agreenumm=parseInt(agreehtml.innerHTML);
					if(agreenumm==0){var j=zeai.addtag('div');j.class('j');dl.append(j);}
					var ul=dl.getElementsByTagName("ul")[0];
					if(zeai.empty(ul)){ul=zeai.addtag('ul');dl.append(ul);}
					setTimeout(function(){ul.insertAdjacentHTML('afterbegin',html_decode(rs.C));},100);
					bbs.addClass('big_small');setTimeout(function(){bbs.remove();},300);
				}
			});
		});
	}
}
function trend_search_btnFn(){ZeaiM.div_left({obj:trend_so,w:28});}
